/*
 * Package il.ac.biu.cs.grossmm.test.test3
 * File Server.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package il.ac.biu.cs.grossmm.tests.fooAdapters;

import il.ac.biu.cs.grossmm.api.cpp.CppServiceManager;
import il.ac.biu.cs.grossmm.api.flow.ActiveDataManager;
import il.ac.biu.cs.grossmm.api.presence.Registrar;
import il.ac.biu.cs.grossmm.api.sql.SqlDataSource;
import il.ac.biu.cs.grossmm.impl.activeData.ActiveDataManagerImpl;
import il.ac.biu.cs.grossmm.impl.cpp.CppManager;
import il.ac.biu.cs.grossmm.impl.hsqldb.DataSourceAdapter;
import il.ac.biu.cs.grossmm.impl.presence.SqlRegistrar;
import il.ac.biu.cs.grossmm.impl.server.RegistryServer;

public class Server extends RegistryServer {

	Server() {
		register(SqlDataSource.class, new DataSourceAdapter(
			"jdbc:hsqldb:file:testpres_db", "sa", ""));
		
		registerClass(ActiveDataManager.class, ActiveDataManagerImpl.class);
		//registerClass(Registrar.class, SqlRegistrar.class);
		registerClass(CppServiceManager.class, CppManager.class);
		registerClass(FooProvider.class);
		registerClass("auth", Authenticator.class);
		registerClass(Registrar.class, Authenticator.class);
		registerClass("publisher", Publisher.class);
		registerClass("aggregator", FooAggregator.class);
		registerClass("filter", PrivacyFilter.class);
		registerClass("presence2string", FooFormatAdapter.class);
		
		registerClass("subAdapter", FooCppBridge.class);
		registerClass("pubAdapter", PresencePublicationAdapter.class);
		registerClass("rulesPubAdapter", RulesPublicationAdapter.class);
		
//		registerClass("A", SpyPublished.class);
//		registerClass("B", SpyAggregated.class);
//		registerClass("C", SpyFiltered.class);
//		registerClass("D", SpyRules.class);

		// addDependency("pubAdapter", SqlDataSource.class);
		
		addDependency(FooProvider.class, "auth");
		
		// addDependency("subAdapter", "publisher");
		
		addDependency("A", "pubAdapter");
		addDependency("B", "aggregator");
		addDependency("C", "filter");
		addDependency("D", "rulesPubAdapter");
		addDependency("subAdapter", "filter");
		addDependency("filter", "rulesPubAdapter");
		addDependency("subAdapter", "presence2string");
		addDependency("subAdapter", "aggregator");
		addDependency("subAdapter", "aggregator");

//		addToStartup("A");
//		addToStartup("B");
//		addToStartup("C");
//		addToStartup("D");

		addToStartup("subAdapter");
		addToStartup("pubAdapter");
		addToStartup("rulesPubAdapter");
	}
	
	public static void main(String[] args) throws InterruptedException
	{
		Server server = new Server();
		
		try {
			server.start();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		Thread.sleep(10000000);
		
		server.stop();
	}
}
